import Vue from 'vue';
import App from './App.vue';
import VueRouter from 'vue-router';

import iView from 'iview';
import 'iview/dist/styles/iview.css';
import { routes } from './routes';
import axios from 'axios';
import VueAxios from 'vue-axios';
import { store } from './store';
import VueQuillEditor from 'vue-quill-editor';
import 'quill/dist/quill.core.css';
import 'quill/dist/quill.snow.css';
import 'quill/dist/quill.bubble.css';
Vue.use(VueAxios, axios);

// axios.interceptors.request.use(
// 	function(config){
// 	axios.defaults.headers.common['Authorization']=
// 	'Bearer ' + store.state.token;
// 	return config;
// },function(err){
// 	return Promise.reject(err)
// });
//axios.defaults.headers.common['Authorization']=AUTH_TOKEN;
axios.interceptors.request.use(
	config=>{
		if(store.state.token){
			//console.log(store.state.token);
			config.headers.Authorization=`Bearer ${store.state.token}`;
		}
		return config;
	},err=>{
		return Promise.reject(err)
	});
Vue.use(iView);

Vue.use(VueRouter);

Vue.use(VueQuillEditor);

const router = new VueRouter({
    routes: routes, // 可以直接写成routes
    mode: 'hash' // mode设置成history，那么地址就可以请求http://localhost:8080/user
});
new Vue({
	el: '#app',
	router,
    store,
    render: h => h(App) // rendera6b1ed
});